package android.tusnotas.util;

import android.content.Context;
import android.tusnotas.model.TusNotasModel;

public class PropertyLoader {
	
	private static PropertyLoader propertyLoader = null;
	
	public static String USERNAME="";
	public static String PASSWORD="";
	public static String HASH="";
	public static Integer FREQUENCY=0;
	public static Integer NOTIF_LEVEL=0;
	public static Integer NUM_WRONG_PASS=0;
	public static Integer PUSH_FREQUENCY=60*1000*15; //15 min
	public static String PUSH_SUBSCRIBED="false";
	
	public static PropertyLoader getInstance(){
		if (propertyLoader==null)
			propertyLoader = new PropertyLoader();
		return propertyLoader;
	}
	
	public static PropertyLoader getInstance(Context c){
		USERNAME = TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.USERNAME).getValue();
		PASSWORD = TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.PASSWORD).getValue();
		HASH = TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.HASH).getValue();
		FREQUENCY = new Integer(TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.FREQUENCY).getValue());
		NOTIF_LEVEL = new Integer(TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.NOTIF_LEVEL).getValue());
		NUM_WRONG_PASS = new Integer(TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.NUM_WRONG_PASS).getValue());
		PUSH_FREQUENCY = new Integer(TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.PUSH_FREQUENCY).getValue());
		PUSH_SUBSCRIBED = TusNotasModel.getTusNotasModel(c).selectPropertyByKey(Properties.PUSH_SUBSCRIBED).getValue();
		
		if (propertyLoader==null)
			propertyLoader = new PropertyLoader();
		return propertyLoader;
	}
	
	private PropertyLoader(){}

}
